package com.xk._01基础篇._02动态数组;

import java.util.Objects;

/**
 * @description:
 * @author: xu
 * @date: 2022/9/14 21:50
 */
public class Person {
    private Integer id;
    private String name;

    public Person(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Person)) return false;
        Person person = (Person) o;
        return Objects.equals(id, person.id) && Objects.equals(name, person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("person finalize" + this);
    }
}
